package com.funcourse.demo.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.LinkedHashSet;
import java.util.Set;

@Data
@Document
@JsonInclude(JsonInclude.Include.NON_NULL)
public class User {

  String avatarUrl;
  String nickName;
  @Indexed
  String webOpenId;
  @Indexed
  String weletOpenId;
  @Indexed
  Set<String> weletOpenIds = new LinkedHashSet<>();
  String sessionKey;
  @Indexed
  String unionId;
  @Indexed
  String token;
  String role;
  String organizationId;
  @Id
  String id;
  @Indexed
  String mobile;
  @ApiModelProperty("工号/卡号/学号")
  String cardNumber;
  Boolean activated;

  protected static final String MASK_STRING="******";

  protected void clearPrivateData() {
    this.setWeletOpenId(null);
    this.setWebOpenId(null);
    this.setUnionId(null);
    this.setToken(null);
    this.setMobile(null);
    this.setSessionKey(null);
    this.setCardNumber(null);
    this.setWeletOpenIds(null);
  }
  public Boolean getActivated(){
    return null == activated?true:activated;
  }

}
